package com.tarena.lbs.basic.web.rpc;

import com.tarena.lbs.basic.api.BasicApi;
import com.tarena.lbs.basic.web.service.AdminService;
import com.tarena.lbs.pojo.basic.bo.AdminBO;
import com.tarena.lbs.pojo.basic.dto.AdminDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@DubboService
@Component
@Slf4j
public class BasicApiImpl implements BasicApi {
    @Autowired
    private AdminService adminService;
    @Override
    public AdminDTO getAdminDetail(Integer id) {
        log.info("远程调用查询商家信息:{}",id);
        try{
            AdminBO adminBO=adminService.adminDetail(id);
            if (adminBO!=null){
                adminBO.setAccountPassword(null);
                AdminDTO adminDTO = new AdminDTO();
                BeanUtils.copyProperties(adminBO,adminDTO);
                return adminDTO;
            }
        }catch (Exception e){
            log.error("远程调用查询商家信息失败:{}",e);
        }
        return null;
    }
}
